package LiuLiangPre;

import com.csvreader.CsvReader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;


public class test1 {
    public static void main(String[] args) throws IOException {
        CsvReader csvReader = new CsvReader("C:\\Users\\Lenovo\\Desktop\\中兴捧月\\train_step1.csv", ',', Charset.forName("UTF-8"));

        // 如果你的文件没有表头，这行不用执行
        // 这行不要是为了从表头的下一行读，也就是过滤表头
        csvReader.readHeaders();
       // HashMap<String,Student> hashMap =new HashMap<>();
        ArrayList<Student> arrayList = new ArrayList<>();
        // 读取每行的内容
        while (csvReader.readRecord()) {
            // 获取内容的两种方式
            // 1. 通过下标获取
          //  System.out.println(csvReader.get(0));
          //  System.out.println(csvReader.get(1));
          //  System.out.println(csvReader.get(2));
            Student student = new Student();
            student.setDate(csvReader.get(1));
            student.setId( csvReader.get(0));
            //hashMap.put(String.valueOf(student.getId()),student);
            arrayList.add(student);
        }
        for (Student student : arrayList) {
            String id=student.getId();
            String date=student.getDate();
            float value =student.getValue();
        }
//        for (String key : hashMap.keySet()) {
//            System.out.println("key= " + key + " and value= " + hashMap.get(key));
//        }


    }


}


